home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 031a / owlbwcc.zip / BDEFCASE.CPP < prev    next >
C/C++ Source or Header  |  1992-01-26  |  4KB  |  115 lines

  1. /**********************************************************************/
  2. /*                  BDEFCASE.cpp by Bob Bourbonnais                   */
  3. /*              released to the public domain 1/26/92                 */
  4. /*           This program shows how to trap for individual            */
  5. /*           Button messages in the DefChild Process using            */
  6. /*                          switch and case.                          */
  7. /*         This is the old style of windows message processing        */
  8. /*         It is recommended that the newer Dynamic Dispatch          */
  9. /*    Virtual Table, DDVT, style be used instead of switch and case.  */
  10. /*               See BDDVTBTN.cpp for an example of DDVT.             */
  11. /**********************************************************************/
  12. #include <owl.h>
  13. #include <dialog.h>
  14. #include "bwcc.h"                        // needed for BWCC
  15.  
  16. class TMyDialog : public TDialog
  17.   {
  18.   public:
  19.     TMyDialog(LPSTR lpDialogName)          // constructor calls
  20.       : TDialog(NULL,lpDialogName)         // base class constructor
  21.       {
  22.       BWCCGetVersion();    // activate Borland Windows Custom Controls
  23.       }
  24.     virtual void DefChildProc(RTMessage Msg); // redefined default
  25.                           // message processing
  26.     // Note: if this is a Window instead of a dialog box, then
  27.     // redefine DefCommandProc instead.
  28.   };
  29.  
  30. void TMyDialog::DefChildProc(RTMessage Msg)
  31.   {
  32.   switch (Msg.WParam)    // switch and case to process button messages
  33.     {                    // this is the old style of message processing
  34.     case (3):            // The next program, BDDVTBTN, shows a much
  35.       {                  // better way of processing individual button
  36.       MessageBeep(0);    // messages
  37.       BWCCMessageBox(HWindow,"Button #3 The Abort Button Was Pressed",
  38.                  "Button Pressed",MB_OK);
  39.       break;
  40.       };
  41.     case (4):
  42.       {
  43.       MessageBeep(0);
  44.       BWCCMessageBox(HWindow,"Button #4 The Retry Button Was Pressed",
  45.                  "Button Pressed",MB_OK);
  46.       break;
  47.       };
  48.     case (5):
  49.       {
  50.       MessageBeep(0);
  51.       BWCCMessageBox(HWindow,"Button #5 The Ignore Button Was Pressed",
  52.                  "Button Pressed",MB_OK);
  53.       break;
  54.       }
  55.     case (6):
  56.       {
  57.       MessageBeep(0);
  58.       BWCCMessageBox(HWindow,"Button #6 The Yes Button Was Pressed",
  59.                  "Button Pressed",MB_OK);
  60.       break;
  61.       }
  62.     case (7):
  63.       {
  64.       MessageBeep(0);
  65.       BWCCMessageBox(HWindow,"Button #7 The No Button Was Pressed",
  66.                  "Button Pressed",MB_OK);
  67.       break;
  68.       }
  69.     case (8):
  70.       {
  71.       MessageBeep(0);
  72.       BWCCMessageBox(HWindow,"Button #8 The Button that says Button Was Pressed",
  73.                  "Button Pressed",MB_OK);
  74.       break;
  75.       }
  76.     default:
  77.       {
  78.       MessageBeep(0);
  79.       BWCCMessageBox(HWindow,"Message Out of range","Error",MB_OK);
  80.       break;
  81.       }
  82.     }
  83.   TDialog::DefChildProc(Msg);
  84.   };
  85.  
  86. class TDialog1App : public TApplication  // Application Class to contain
  87.   {                                      // the application
  88.   public:
  89.     TDialog1App(LPSTR lpName, HANDLE hInstance,  // constructor calls the
  90.         HANDLE hPrevInstance,            // base class constructor
  91.         LPSTR lpCmdLine, int nCmdShow)
  92.         :TApplication(lpName, hInstance,
  93.                   hPrevInstance,
  94.                   lpCmdLine, nCmdShow) {};
  95.  
  96.     virtual void InitMainWindow(); // overrides base class InitMainWindow
  97.   };
  98.  
  99. void TDialog1App::InitMainWindow() // to initialize a dialog box
  100.   {                                // as the main window
  101.   MainWindow = new TMyDialog("MAINWINDOWDIALOG");
  102.   }
  103.  
  104. int PASCAL WinMain(HANDLE hInstance,              // main entry point from
  105.            HANDLE hPrevInstance,          // windows to this program
  106.            LPSTR lpCmdLine , int nCmdShow)
  107.   {
  108.   TDialog1App Dialog1("Dialog Tester",hInstance,  // create instance of
  109.                hPrevInstance,             // the dialog application
  110.                lpCmdLine,nCmdShow);
  111.   Dialog1.Run();                                  // run it
  112.   return (Dialog1.Status);                        // exit
  113.   }
  114. /**********************************************************************/
  115.